package com.yc.jpyy.mobile.controller;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yc.jpyy.base.bean.RestResponse;
import com.yc.jpyy.base.controller.BaseController;
import com.yc.jpyy.mobile.dao.BizDao;
import com.yc.jpyy.mobile.service.BizService;

@Controller
@RequestMapping(value = "/student")
public class UpdateDriverSchoolConsultNumController extends BaseController {

	@Autowired
	private BizService bizService;

	@Autowired
	private BizDao bizDao;

	/**
	 * 修改学员个人信息
	 * @param request
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	@SuppressWarnings("finally")
	@RequestMapping(value = "/updateDriverSchoolConsultNum", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
	public @ResponseBody String updateDriverSchoolConsultNum(HttpServletRequest request)
			throws UnsupportedEncodingException {

		RestResponse response = new RestResponse();

		// 影响行数
		int i = 0;

		try {
			// 驾校id
			String id = request.getParameter("id");
			String drivetype = request.getParameter("drivetype");
			if(null!=id&&!id.equals("")){
				
				Map<String, Object> valMap = new HashMap<String, Object>();
				valMap.put("id", id);
				valMap.put("drivetype", drivetype);
				// 修改个人信息
				i = bizDao.updateDriveSchoolConsultNum(valMap);
				if (i == 0){
					response.setErrorcode(1);
					response.setMessage("驾校咨询数量未更新！");
				}
			}else{
				response.setErrorcode(1);
				response.setMessage("缺少必填字段！");
			}
			
		} catch (Exception e) {
		    System.out.println("UpdatePwdController:"+ e.toString());
		    response.setErrorcode(1);
			response.setMessage("驾校咨询数量更新失败！");
		} finally {
			return response.toJSON();
		}

	}

}
